import java.util.Calendar;

public class MyDate
{
    private int year, month, day;
    private static int thisYear;

    static
    {
        thisYear=2021;
    }

    public MyDate(int year,int month,int day)
    {
        this.set(year,month,day);
    }

    public MyDate()
    {
        this(1970,1,1);
    }

    public MyDate(MyDate date)
    {
        this.set(date);
    }

    public MyDate(Calendar cal)
    {
        this(cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH));
    }

    public void set(int year,int month,int day)
    {
        this.year=year;
        this.month=(month>=1&&month<=12)?month:1;
        this.day=(day>=1&&day<=MyDate.daysOfMonth(this.year,this.month))?day:1;
    }

    public void set(MyDate date)
    {
        this.set(date.year,date.month,date.day);
    }

    public int getYear()
    {
        return this.year;
    }

    public int getMonth()
    {
        return this.month;
    }

    public  int getDay()
    {
        return  this.day;
    }

    public String toString()
    {
        return year+"年"+String.format("%02d",month)+"月"+String.format("%02d",day)+"日";
    }

    public static int getThisYear()
    {
        return thisYear;
    }

    public static boolean isLeapYear(int year)
    {
        return year%400==0||(year%100!=0&&year%4==0);
    }

    public boolean isLeapYear()
    {
        return isLeapYear(this.year);
    }

    public boolean equals(MyDate date)
    {
        return this==date ||date!=null&&this.year==date.year&&this.month==date.month&&this.day==date.day;
    }

    public static int daysOfMonth(int year,int month)
    {
        switch (month)
        {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                return 31;
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            case 2:
                return MyDate.isLeapYear(year)?29:28;
            default:
                return 0;
        }
    }

    public int daysOfMonth()
    {
        return daysOfMonth(this.year,this.month);
    }

    public void tomorrow()
    {
        this.day=this.day%this.daysOfMonth()+1;
        if(this.day==1)
        {
            this.month=this.month%12+1;
            if(this.month==1)
                ++this.year;
        }
    }

    public MyDate yesterday()
    {
        MyDate date=new MyDate(this);
        --date.day;
        if(date.day==0)
        {
            date.month=(date.month-2+12)%12+1;
            if(date.month==12)
                --date.year;
            date.day=daysOfMonth(date.year,date.month);
        }
        return date;
    }

    public boolean compareByYear(int year)
    {
        return this.year==year;
    }

    public boolean compareByMonth(int month)
    {
        return this.month==month;
    }

    public boolean compareByDay(int day)
    {
        return this.day==day;
    }

    public Calendar getCalender()
    {
        Calendar cal=Calendar.getInstance();
        cal.set(year,month-1,day);
        return cal;
    }
}
